package dashboard;

import events.packageEvents.PackageCreatedEvent;
import framework.core.VirtualClock;
import framework.events.Event;
import framework.events.EventBroker;
import framework.utils.Utils;

public class DroppedPackagesGraph extends Graph {

	private static final long serialVersionUID = -552119508513412982L;

	public DroppedPackagesGraph(String title, String xAxis, String yAxis,
			String legend) {
		super(title, xAxis, yAxis, legend);
		EventBroker.getEventBroker().register(this);
	}

	@Override
	public void handleEvent(Event event) {
		if(event instanceof PackageCreatedEvent){
			int time = Utils.microsecondsToSeconds(VirtualClock.getClock().getCurrentTime());
			this.addValue(time, this.getCounter());
		}
	}
}
